<html>
<head>
    <title>网页标题 </title>
</head>
<body>
<script type="text/javascript" src="./js/socket.io.js"></script>
<script type="text/javascript" src="./js/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(function(){
	var socket = io.connect('ws://localhost:6001');
    socket.on('message', function (data) {	
	console.log("server:"+data); 
	var obj = JSON.parse(data);
	console.log('channel:'+ obj.channel); 
	console.log('event:'+ obj.message.event);	
	var arr = obj.message.data.user_data;	 
	console.log(arr);
    var arr2 = JSON.parse(arr);
    var res = arr2.map(function (item,index,arr2) {	 
		if(item.user_id==376) alert('您关注的分析师:'+item.name+',在['+item.lottery_name+'],发布了一个计划!');
	}); 
	 
     
    });
});
</script>
查看websock接收消息
</body>
</html>